package com.lanou.demo.backgrounddemo.service.impl;

import com.lanou.demo.backgrounddemo.mapper.ContentMapper;
import com.lanou.demo.backgrounddemo.service.ContentService;
import com.lanou.entity.entity.ContentEntity;
import com.lanou.entity.utils.IdsResultUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by 常宏盛
 * Date: 2019/7/15 10:30
 **/
@Service
public class ContentServiceImpl implements ContentService {

    @Resource
    private ContentMapper contentMapper;

    @Override
    public List<ContentEntity> list(Long categoryId, int page, int rows) {
        int offset = (page - 1) * rows;
        return this.contentMapper.list(categoryId, offset, rows);
    }

    @Override
    public int save(ContentEntity content) {
        return this.contentMapper.save(content);
    }

    @Override
    public int edit(ContentEntity content) {
        return this.contentMapper.edit(content);
    }

    @Override
    public int delete(String[] ids) {
        List<Long> idsList = IdsResultUtils.idsResultList(ids);
        return this.contentMapper.delete(idsList);
    }

}
